//
//  UIImageView+Master.m
//  HiMaster3
//
//  Created by jinghao on 15/12/23.
//  Copyright © 2015年 jinghao. All rights reserved.
//

#import "UIImageView+Master.h"

@implementation UIImageView (Master)
- (void)setImageWithURLString:(NSString *)url{
    [self setImageWithURLString:url placeholderImagetype:PlaceholderType_Default];
}

- (void)setImageWithURLString:(NSString *)url placeholderImagetype:(PlaceholderType)placeholderType{
    UIImage * placeholder;
    switch (placeholderType) {
        case PlaceholderType_Default:
             placeholder =[UIImage imageNamed:@"LoadingDefault"];
            
        case PlaceholderType_Small:
            placeholder = [UIImage imageNamed:@"weixianshi-small"];
            break;
        case PlaceholderType_Big:
            placeholder =[UIImage imageNamed:@"weixianshi-big"];
            break;
    }
    
    
    NSURL * prepare =[NSURL URLWithString:url];
    if(prepare.scheme.length >0){
         [self sd_setImageWithURL:prepare placeholderImage:placeholder];
        return;
    }
    url = [url masterFullImageUrl];
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeholder];
//    self.browserImages = @[url];
//    self.canBrowser = YES;
}

- (void)setImageWithURLString:(NSString *)url placeholderImage:(UIImage *)placeholder{
    url = [url masterFullImageUrl];
    if(placeholder == nil){
         placeholder =[UIImage imageNamed:@"LoadingDefault"];
    }
    [self sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:placeholder];

}

@end
